<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #container {
            width: 600px;
            height: 600px;
        }
    </style>
</head>

<body>
    <div id="container"></div>
    <script type="text/javascript">
        window._AMapSecurityConfig = {
            securityJsCode: "80b80a2bc7f7c4da191e0c96de08601b",
        };
    </script>
    <script src="https://webapi.amap.com/loader.js"></script>
    <script type="text/javascript">
        AMapLoader.load({
            key: "ee321cf794b6b10b8b4fd7e47290e55a", //申请好的Web端开发者 Key，调用 load 时必填
            version: "2.0", //指定要加载的 JS API 的版本，缺省时默认为 1.4.15
        })
            .then((AMap) => {
                const map = new AMap.Map("container", {
                    center: [91.118463, 29.654471]
                });

                const infoWindow = new AMap.InfoWindow({
                    //创建信息窗体
                    isCustom: true, //使用自定义窗体
                    content: "<div>西藏布达拉宫</div>", //信息窗体的内容可以是任意html片段
                    offset: new AMap.Pixel(16, -45),
                });
                const onMarkerClick = function (e) {
                    infoWindow.open(map, e.target.getPosition()); //打开信息窗体
                    //e.target就是被点击的Marker
                };
                const marker = new AMap.Marker({
                    position: [91.118463, 29.654471],
                });
                map.add(marker);
                marker.on("click", onMarkerClick); //绑定click事件
            })
            .catch((e) => {
                console.error(e); //加载错误提示


            });
    </script>
</body>

</html>